package com.bk.ouat.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bk.ouat.dao.CategoryDao;
import com.bk.ouat.dao.StoryDao;
import com.bk.ouat.dto.StoryDto;

@Service
public class StoryService {
	
	@Autowired
	private StoryDao storyDao;
	
	@Autowired
	private CategoryDao cateDao;

	public List<StoryDto> listByCategoryId(int category_id) {
		return storyDao.listByCategoryId(category_id);
	}

	public StoryDto detail(StoryDto story) {
		
		// view count +1
		storyDao.increaseViewCount(story);
		
		// read yn = y
		
		// select info
		return storyDao.detail(story);
	}

	public String getHeaderNameByCategoryId(int category_id) {
		return cateDao.getHeaderNameByCategoryId(category_id);
	}

}
